define(['angular'], function(angular) {
    angular.module('services', [])
        .factory('header', [function() {
            return {
                templateUrl: './template/header.html',
                homePath: './index.html'
            };
        }]).factory('headerTitle', ['$timeout', function($timeout) {
            var titleJson = [
								{"id":'1',"title":"赢火虫"},
                                {"id":'2',"title":"律师费计算"},
                                {"id":'3',"title":"请选择省份"},
                                {"id":'4',"title":""},
                                {"id":'5',"title":"诉讼费计算"},
                                {"id":'6',"title":"案件类型"},
                                {"id":'7',"title":"诉讼费用交纳办法"}
                             ];
            
            var sendData = {
            		getTitleName : getTitleName
            };
            
            function getTitleName(id){
            	var title = "";
            	for(var i=0;i<titleJson.length;i++){
            		if(titleJson[i].id === id){
            			title = titleJson[i].title;
            			break;
            		}
            	}
            	return title;
            }
            
            return sendData;
        }]).factory('bizProxy', ['$http','$rootScope','$timeout', function($http,$rootScope,$timeout) {
        	return {
        		queryProxyBizData : function(serviceName, headerInfo, bizInfo, successCallBackFn, failCallBackFn) {

                    if(headerInfo == null){
                            headerInfo = {};
                            headerInfo.pageNum = "";
                            headerInfo.pageSize = "";
                            headerInfo.sessionId = "";
                        }else{
                            if(headerInfo.pageSize == null){
                                headerInfo.pageSize = "";
                        }else{
                            headerInfo.pageSize = headerInfo.pageSize+"";
                        }
                            if(headerInfo.pageNum == null){
                                headerInfo.pageNum = "";
                        }else{
                            headerInfo.pageNum = headerInfo.pageNum+"";
                        }
                        
                        
                            if(headerInfo.sessionId == null){
                                headerInfo.sessionId = "";
                        }else{
                            headerInfo.sessionId = headerInfo.sessionId+"";
                        }

                     }

    			//请求代理查询我的贷款列表
	    			wh.biz(serviceName,headerInfo,bizInfo,
	    				function(ret){
	    					if(ret != "" && ret != null && ret != '{}' && ret != 'null'){
	    						var tempData = JSON.parse(ret);
	    						if(tempData.isSuccess == "T"){
	    							successCallBackFn(tempData);
	    						}else{
	    							failCallBackFn(tempData);
	    						}
	    					}else{
	    						if(serviceName == "userLogin"){
	    							failCallBackFn("");
	    						}else{
	    							failCallBackFn({"errorMsg":"网络异常"});
	    						}
	    					}
	    			 	}, 
	    			 function(){});
	    		}
        	};
    }])
	;
});